<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,2,3,4,5]
        var arr1 = [5,4,3,2,1]
        
        // concat---连接数组
        var arr2 = arr.concat(arr1);
        console.log(arr2);

        // join 转成字符串
        var arr3 = arr.join();
        console.log(arr3);

        //pop
        var res = arr.pop();
        console.log(arr)
        console.log(res)

        //push
        var res1 = arr.push(5)
        console.log(arr)
        console.log(res1)

        //shift
        var res2 = arr.shift()
        console.log(arr)
        console.log(res2)

        //unshift
        var res3 = arr.unshift(1)
        console.log(arr)
        console.log(res3)

        // slice 
        var res4 = arr.slice(1,3)
        console.log(res4);

        //reverse
        arr1.reverse()
        console.log(arr1)

        //sort 排序
        arr1.sort(
            function(a,b){
                return a-b;
            }
        );
        console.log(arr1);

        //splice 增加、删除元素
        arr.splice(4,1,5,6);
        console.log(arr)
        
    </script>
</body>
</html>